
package cn.xabad.commons.plist;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.String;


public class Stringer {

	private StringBuilder builder;

	
	public Stringer() {
		builder = new StringBuilder();
	}

	
	public Stringer(String val) {
		builder = new StringBuilder(val);
	}

	
	public StringBuilder newBuilder() {
		builder.setLength(0);
		return builder;
	}

	
	public StringBuilder getBuilder() {
		return builder;
	}

	
	public static Stringer convert(InputStream is) throws IOException {
		
		Stringer ret = new Stringer();
		if (is != null) {
			char[] buffer = new char[1024];
			try {
				Reader reader = new BufferedReader(new InputStreamReader(is,
						"UTF-8"));
				int n;
				while ((n = reader.read(buffer)) != -1) {
					ret.getBuilder().append(buffer, 0, n);
				}
			} finally {
				is.close();
			}
		}
		return ret;
	}

}
